<template>
  <div id="centerLeft1">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <!--        导热油-->
        <!--        蒸汽锅炉-->
        <!--        空压制氮-->
        <!--        冷水机组-->
        <!--        开了几台-->
        <span>
          <icon name="chart-bar" class="text-icon"></icon>
        </span>
        <div class="d-flex">
          <span class="fs-xl text mx-2">动力站设备情况</span>
          <dv-decoration-3 class="dv-dec-3"/>
        </div>
      </div>
      <div class="d-flex jc-center">
        <CenterLeft1Chart ref="CenterLeft1Chart"/>
      </div>
      <!-- 4个主要的数据 -->
      <div class="bottom-data">
        <div
            class="item-box mt-2"
            v-for="(item, index) in numberData"
            :key="index"
        >
          <div class="d-flex">
            <dv-digital-flop class="dv-digital-flop" :config="item.number"/>
          </div>
          <p class="text" style="text-align: center;">
            {{ item.text }}
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import CenterLeft1Chart from '@/components/echart/centerLeft/centerLeft1Chart'
import {getlatestdata} from '@/api/index'

export default {
  data() {
    return {
      numberData: []
    }
  },
  components: {
    CenterLeft1Chart
  },
  mounted() {
    getlatestdata({
      "detailShow": false, "retTsType": "ISOStr", "sensors": [
        {
          "nodeId": 737,
          "sensorName": "负荷反馈",
          "sensorType": "monitor",
          "key": "guolu"
        },
        {
          "nodeId": 738,
          "sensorName": "负荷反馈",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 739,
          "sensorName": "负荷反馈",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 740,
          "sensorName": "负荷反馈",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 550,
          "sensorName": "AC207离心机_压缩机状态",
          "sensorType": "monitor",
          "key": "guolu"
        },
        {
          "nodeId": 550,
          "sensorName": "AC206离心机_压缩机状态",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 550,
          "sensorName": "AC205离心机_压缩机状态",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 550,
          "sensorName": "AC204离心机_压缩机状态",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 550,
          "sensorName": "AC203离心机_压缩机状态",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 550,
          "sensorName": "AC202螺杆机运行",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 550,
          "sensorName": "AC201螺杆机运行",
          "sensorType": "monitor",
          "key": "guolu"
        },
        {
          "nodeId": 552,
          "sensorName": "BNP201制氮机运行",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 552,
          "sensorName": "BNP202制氮机运行",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 552,
          "sensorName": "BNP203制氮机运行",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 552,
          "sensorName": "BNP204制氮机运行",
          "sensorType": "monitor",
          "key": "guolu"

        },
        {
          "nodeId": 552,
          "sensorName": "BNP205制氮机运行",
          "sensorType": "monitor",
          "key": "guolu"
        }]
    }).then(res => {
      let arr = [
        {
          number: {
            number: [0],
            toFixed: 0,
            textAlign: 'center',
            content: '{nt}',
            style: {
              fontSize: 24
            }
          },
          text: '导热油启动数量'
        },
        {
          number: {
            number: [1144],
            toFixed: 0,
            textAlign: 'center',
            content: '{nt}',
            style: {
              fontSize: 24
            }
          },
          text: '蒸汽锅炉启动数量'
        },
        {
          number: {
            number: [361],
            toFixed: 0,
            textAlign: 'center',
            content: '{nt}',
            style: {
              fontSize: 24
            }
          },
          text: '空压启动数量'
        },
        {
          number: {
            number: [157],
            toFixed: 0,
            textAlign: 'center',
            content: '{nt}',
            style: {
              fontSize: 24
            }
          },
          text: '制氮启动数量'
        },
        {
          number: {
            number: [0],
            toFixed: 0,
            textAlign: 'center',
            content: '{nt}',
            style: {
              fontSize: 24
            }
          },
          text: '冷水机启动数量'
        }
      ]
      let gi = 0//锅炉
      let yi = 0//空压
      let zj = 0//制氮
      res.map(v => {
        if (v.sensorName == '负荷反馈' && v.v > 0) {
          gi++
        }
        if (v.sensorName.indexOf('离心机_压缩机状态') && v.v == 3) {
          yi++
        }
        if (v.sensorName == 'AC201螺杆机运行' && v.v == 1) {
          // debugger
          console.log('v11111111111111111=>', v)

          console.log('111=>', 111)
          yi++
        }
        if (v.sensorName == 'AC202螺杆机运行' && v.v == 1) {
          // debugger
          console.log('v11111111111111111=>', v)

          console.log('111=>', 111)
          yi++
        }
        if (v.nodeId == 552 && v.v == 1) {
          zj++
        }
      })
      console.log('zj=>', zj)
      arr[1].number.number = [gi]
      arr[2].number.number = [yi]
      arr[3].number.number = [zj]
      this.numberData = arr
      this.$refs.CenterLeft1Chart.initData(arr)
    })

  },
  methods: {
    // changeTiming() {
    //   setInterval(() => {
    //     this.changeNumber()
    //   }, 3000)
    // },
    // changeNumber() {
    //   this.numberData.forEach((item, index) => {
    //     item.number.number[0] += ++index
    //     item.number = {...item.number}
    //   })
    // }
  }
}
</script>

<style lang="scss" scoped>
$box-width: 600px;
$box-height: 410px;

#centerLeft1 {
  padding: 16px;
  height: $box-height;
  width: $box-width;
  border-radius: 10px;

  .bg-color-black {
    height: $box-height - 30px;
    border-radius: 10px;
  }

  .text {
    font-size: 16px !important;
    color: #c3cbde;
  }

  .dv-dec-3 {
    position: relative;
    width: 100px;
    height: 20px;
    top: -3px;
  }

  .bottom-data {
    .item-box {
      & > div {
        padding-right: 5px;
      }

      font-size: 14px;
      float: left;
      position: relative;
      width: 33.3%;
      color: #d3d6dd;

      .dv-digital-flop {
        width: 120px;
        height: 30px;
      }

      // 金币
      .coin {
        position: relative;
        top: 6px;
        font-size: 20px;
        color: #ffc107;
      }

      .colorYellow {
        color: yellowgreen;
      }

      p {
        text-align: center;
      }
    }
  }
}
</style>
